package com.Cychat.schedule.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.Cychat.commons.entity.pojo.PetSchedule;
import com.Cychat.schedule.mapper.PetScheduleMapper;
import com.Cychat.schedule.service.PetScheduleService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
/**
 * Auther: 谢宝辉  <br/>
 * Date: 2025/10/28:20:13  <br/>
 * Description: 宠物日程服务实现类
 */

@Service
public class PetScheduleServiceImpl extends ServiceImpl<PetScheduleMapper, PetSchedule> implements PetScheduleService {

    /**
     * Auther: 谢宝辉  <br/>
     * Date: 2025/10/28:20:14  <br/>
     * Description: 根据主人ID获取宠物日程列表
     */
    @Override
    public List<PetSchedule> getSchedulesByOwnerId(Integer ownerId) {
        LambdaQueryWrapper<PetSchedule> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PetSchedule::getOwnerId, ownerId)
                   .orderByDesc(PetSchedule::getScheduleDate);
        return list(queryWrapper);
    }

    /**
     * Auther: 谢宝辉  <br/>
     * Date: 2025/10/28:20:14  <br/>
     * Description: 根据宠物ID获取宠物日程列表
     */
    @Override
    public List<PetSchedule> getSchedulesByScheduleId(Integer scheduleId) {
        LambdaQueryWrapper<PetSchedule> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PetSchedule::getScheduleId, scheduleId)
                   .orderByDesc(PetSchedule::getScheduleDate);
        return list(queryWrapper);
    }

    /**
     * Auther: 谢宝辉  <br/>
     * Date: 2025/10/28:20:14  <br/>
     * Description: 根据日程日期和主人ID获取宠物日程列表
     */
    @Override
    public List<PetSchedule> getSchedulesByDateAndOwnerId(Date scheduleDate, Integer ownerId) {
        LambdaQueryWrapper<PetSchedule> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(PetSchedule::getOwnerId, ownerId)
                   .eq(PetSchedule::getScheduleDate, scheduleDate);
        return list(queryWrapper);
    }


}